package br.com.vertigo.sgci.entity;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@SuppressWarnings("serial")
@Entity
@Table(name = "cliente", catalog = "sgci_project")
public class Cliente implements java.io.Serializable {

	private Long idCliente;
	private String nome;
	private String nomeTransient;

	public Cliente() {
	}

	public Cliente(String nome, String nomeTransient) {
		this.nome = nome;
		this.nomeTransient = nomeTransient;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID_CLIENTE", unique = true, nullable = false)
	public Long getIdCliente() {
		return this.idCliente;
	}

	public void setIdCliente(Long idCliente) {
		this.idCliente = idCliente;
	}

	@Column(name = "NOME", nullable = false, length = 100)
	@NotNull
	@Length(max = 100)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}
	
	@Transient
	public String getNomeTransient() {
		if(nomeTransient == null){
			nomeTransient = getNome();
		}
		return nomeTransient;
	}

	public void setNomeTransient(String nomeTransient) {
		this.nomeTransient = nomeTransient;
	}
}

